package dao.impl;

import dao.ProductPicInfoDao;
import entity.Product_Pic_Info;
import org.apache.commons.dbutils.QueryRunner;
import org.apache.commons.dbutils.handlers.BeanHandler;
import util.C3P0Util;

import java.sql.SQLException;

public class ProductPicInfoDaoImpl implements ProductPicInfoDao{
	private QueryRunner getQueryRunner(){
		return new QueryRunner(C3P0Util.getDataSource());
	}
	
	@Override
	public Product_Pic_Info getProduct_Pic_InfoById(Integer product_id) {
		QueryRunner qr = this.getQueryRunner();
		String sql = "select * from product_pic_info where product_id = ?";
		Product_Pic_Info ppi = null;
		try {
			ppi = qr.query(sql, product_id,new BeanHandler<Product_Pic_Info>(Product_Pic_Info.class));
		} catch (SQLException e) {
			e.printStackTrace();
		}
		return ppi;
	}

}
